package com.test.collections;
import java.util.*;

/**
 * @author Varun
 * 
 * Practicing operations on various collection classes 
 * Attempting to compare their performance .
 *
 */
public class RandomOpsOnCollections {
	private Map<Integer,Integer> hmap=new HashMap<Integer,Integer>();
	private Map<Integer,Integer> htable= new Hashtable<Integer,Integer>();
	private SortedMap<Integer,Integer> tmap= new TreeMap<Integer,Integer>();
	private Set<Integer> hset= new HashSet<Integer>();
	private List<Integer> alist = new ArrayList();
	private List<Integer> llist = new LinkedList<Integer>();
	private List<Integer> vector= new Vector<Integer>();
	private SortedSet<Integer> tset = new TreeSet<Integer>();
	private List<Integer> stack = new Stack<Integer>();
	private Set<Integer> lhset = new LinkedHashSet<Integer>();
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.out.println("Adding 100 random integers to Hashmap,Hashtable,Treemap,Hashset,ArrayList,LinkedList,Vector,TreeSet,Stack,LinkedHashSet:");
		
	}
	public static double add(Map<Integer,Integer> map,Integer key,Integer value){
		long timeDiff=0;
		long previous=System.currentTimeMillis();
		map.put(key,value);
		long now=System.currentTimeMillis();
		timeDiff=now-previous;
		return timeDiff;
	}
	public static long add(Set<Integer> set,Integer n){
		long timeDiff=0;
		long previous=System.currentTimeMillis();
		set.add(n);
		long now=System.currentTimeMillis();
		timeDiff=now-previous;
		return timeDiff;
	}
	public static long add(List<Integer> list,Integer n){
		long timeDiff=0;
		long previous=System.currentTimeMillis();
		list.add(n);
		long now=System.currentTimeMillis();
		timeDiff=now-previous;
		return timeDiff;
	}
	public static long remove(List<Integer> list,Integer key,Integer value){
		long timeDiff=0;
		return timeDiff;
	}
	
	public static long remove(Set<Integer> set,Integer n){
		long timeDiff=0;
		long previous=System.currentTimeMillis();
		return timeDiff;
	}
	
	public static long remove(List<Integer> list,Integer n){
		long timeDiff=0;
		long previous=System.currentTimeMillis();
		long now=System.currentTimeMillis();
		timeDiff=now-previous;
		return timeDiff;
	}

}
